const graph = require('./graph')

const visited = new Set()
visited.add(2)
const q = [2]

while(q.length) {
    const n = q.shift()
    console.log(n)
    graph[n].forEach(item => {
        if (!visited.has(item)) {
            q.push(item)
            visited.add(item)
        }
    })
}